package kz.kstu.scantest.app.delegate.impl;


import kz.kstu.scantest.app.delegate.api.GuideDelegate;
import kz.kstu.scantest.app.util.locator.ServiceLocator;
import kz.kstu.scantest.app.util.locator.factory.ServiceLocatorFactory;
import kz.kstu.scantest.business.entity.guide.School;
import kz.kstu.scantest.facade.ejb.api.GuideFacade;

import java.util.List;

/**
 * @author Filipp_Stankevich
 *         created: 26.07.11 21:07
 */
public class GuideDelegateImpl implements GuideDelegate {


    @Override
    public List<School> findSchools() {
        return getGuideFacade(false).findSchools();
    }

    @Override
    public School saveSchool(School school) {
        return getGuideFacade(false).saveSchool(school);
    }

    @Override
    public void removeSchool(School school) {
        getGuideFacade(false).removeSchool(school);
    }

    private GuideFacade getGuideFacade(boolean isOnline) {
        ServiceLocator serviceLocator = ServiceLocatorFactory.getServiceLocator(isOnline);
        return serviceLocator.getService(GuideFacade.SERVICE_NAME, GuideFacade.class);
    }
}
